﻿<navigation:Page x:Class="LEEAAttendanceControl.Views.EmployeesShifts" 
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
           xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
           xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"
           xmlns:my="clr-namespace:LEEAAttendanceControl.Web.Services"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="Employees Shifts">
    <Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <LinearGradientBrush x:Key="BackRectangleBrush" EndPoint=".7,1" StartPoint=".7,0">
                <GradientStop Color="#FCFFFFFF" Offset="0.015"/>
                <GradientStop Color="#F7FFFFFF" Offset="0.375"/>
                <GradientStop Color="#E5FFFFFF" Offset="0.6"/>
                <GradientStop Color="#D1FFFFFF" Offset="1"/>
            </LinearGradientBrush>
        </Grid.Resources>
        <ScrollViewer VerticalScrollBarVisibility="Auto">
            <StackPanel Orientation="Vertical">
                <Grid Background="#404041">
                    <TextBlock Text="Employees Shifts" Foreground="White" FontSize="14" FontWeight="Bold" Margin="5,3,3,2"
                               HorizontalAlignment="Left"/>
                </Grid>

                <riaControls:DomainDataSource x:Name="ShAssignmentDataSource" AutoLoad="True" LoadSize="20" PageSize="15"
                                              QueryName="GetShiftAssignmentSummaries"
                                              LoadingData="DomainDataSource_LoadingData">
                    <riaControls:DomainDataSource.DomainContext>
                        <my:LEEAContext />
                    </riaControls:DomainDataSource.DomainContext>
                </riaControls:DomainDataSource>

                <sdk:DataGrid x:Name="ShAssignmentsGrid" AutoGenerateColumns="False" IsReadOnly="True"
                              ItemsSource="{Binding Data, ElementName=ShAssignmentDataSource}">
                    <sdk:DataGrid.RowDetailsTemplate>
                        <DataTemplate>
                            <Border BorderBrush="LightSteelBlue" BorderThickness="1">
                                <Grid HorizontalAlignment="Left" Margin="10">
                                    <riaControls:DomainDataSource x:Name="ShiftsDataSource" AutoLoad="True"
                                                                  QueryName="GetShiftDays"
                                                                  LoadingData="DomainDataSource_LoadingData">
                                        <riaControls:DomainDataSource.DomainContext>
                                            <my:LEEAContext />
                                        </riaControls:DomainDataSource.DomainContext>
                                        <riaControls:DomainDataSource.QueryParameters>
                                            <riaControls:Parameter ParameterName="id" Value="{Binding EmployeeID}"/>
                                        </riaControls:DomainDataSource.QueryParameters>
                                    </riaControls:DomainDataSource>

                                    <sdk:DataGrid AutoGenerateColumns="False" IsReadOnly="True"
                                                  ItemsSource="{Binding Data, ElementName=ShiftsDataSource}">
                                        <sdk:DataGrid.Columns>
                                            <sdk:DataGridTemplateColumn Header="Shift Name" CanUserReorder="False" Width="120"
                                                                    CanUserResize="False">
                                                <sdk:DataGridTemplateColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <Grid Margin="0" Background="{Binding Color}">
                                                            <sdk:Label Content="{Binding ShiftName}" Margin="5,2,2,2"
                                                                       HorizontalAlignment="Left" VerticalAlignment="Center"
                                                                       Foreground="{Binding ForeColor}"/>
                                                        </Grid>
                                                    </DataTemplate>
                                                </sdk:DataGridTemplateColumn.CellTemplate>
                                            </sdk:DataGridTemplateColumn>
                                            <sdk:DataGridTemplateColumn CanUserReorder="False" Width="70" CanUserResize="False">
                                                <sdk:DataGridTemplateColumn.HeaderStyle>
                                                    <Style TargetType="sdk:DataGridColumnHeader">
                                                        <Setter Property="Template">
                                                            <Setter.Value>
                                                                <ControlTemplate>
                                                                    <Grid>
                                                                        <Rectangle Fill="#FF1F3B53" Stretch="Fill"/>

                                                                        <Rectangle Stretch="Fill" Fill="{StaticResource BackRectangleBrush}"/>

                                                                        <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch"
                                                                                   Width="1" HorizontalAlignment="Right"/>

                                                                        <TextBlock Text="Sat" HorizontalAlignment="Center"
                                                                                   VerticalAlignment="Center"/>
                                                                    </Grid>
                                                                </ControlTemplate>
                                                            </Setter.Value>
                                                        </Setter>
                                                    </Style>
                                                </sdk:DataGridTemplateColumn.HeaderStyle>
                                                <sdk:DataGridTemplateColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <Grid Margin="0" Background="{Binding Color}">
                                                            <Ellipse Width="8" Height="8" Fill="{Binding ForeColor}"
                                                                     Opacity="{Binding Saturday}"
                                                                     HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                                        </Grid>
                                                    </DataTemplate>
                                                </sdk:DataGridTemplateColumn.CellTemplate>
                                            </sdk:DataGridTemplateColumn>
                                            <sdk:DataGridTemplateColumn CanUserReorder="False" Width="70" CanUserResize="False">
                                                <sdk:DataGridTemplateColumn.HeaderStyle>
                                                    <Style TargetType="sdk:DataGridColumnHeader">
                                                        <Setter Property="Template">
                                                            <Setter.Value>
                                                                <ControlTemplate>
                                                                    <Grid>
                                                                        <Rectangle Fill="#FF1F3B53" Stretch="Fill"/>

                                                                        <Rectangle Stretch="Fill" Fill="{StaticResource BackRectangleBrush}"/>

                                                                        <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch"
                                                                                   Width="1" HorizontalAlignment="Right"/>

                                                                        <TextBlock Text="Sun" HorizontalAlignment="Center"
                                                                                   VerticalAlignment="Center"/>
                                                                    </Grid>
                                                                </ControlTemplate>
                                                            </Setter.Value>
                                                        </Setter>
                                                    </Style>
                                                </sdk:DataGridTemplateColumn.HeaderStyle>
                                                <sdk:DataGridTemplateColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <Grid Margin="0" Background="{Binding Color}">
                                                            <Ellipse Width="8" Height="8" Fill="{Binding ForeColor}"
                                                                     Opacity="{Binding Sunday}"
                                                                     HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                                        </Grid>
                                                    </DataTemplate>
                                                </sdk:DataGridTemplateColumn.CellTemplate>
                                            </sdk:DataGridTemplateColumn>
                                            <sdk:DataGridTemplateColumn CanUserReorder="False" Width="70" CanUserResize="False">
                                                <sdk:DataGridTemplateColumn.HeaderStyle>
                                                    <Style TargetType="sdk:DataGridColumnHeader">
                                                        <Setter Property="Template">
                                                            <Setter.Value>
                                                                <ControlTemplate>
                                                                    <Grid>
                                                                        <Rectangle Fill="#FF1F3B53" Stretch="Fill"/>

                                                                        <Rectangle Stretch="Fill" Fill="{StaticResource BackRectangleBrush}"/>

                                                                        <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch"
                                                                                   Width="1" HorizontalAlignment="Right"/>

                                                                        <TextBlock Text="Mon" HorizontalAlignment="Center"
                                                                                   VerticalAlignment="Center"/>
                                                                    </Grid>
                                                                </ControlTemplate>
                                                            </Setter.Value>
                                                        </Setter>
                                                    </Style>
                                                </sdk:DataGridTemplateColumn.HeaderStyle>
                                                <sdk:DataGridTemplateColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <Grid Margin="0" Background="{Binding Color}">
                                                            <Ellipse Width="8" Height="8" Fill="{Binding ForeColor}"
                                                                     Opacity="{Binding Monday}"
                                                                     HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                                        </Grid>
                                                    </DataTemplate>
                                                </sdk:DataGridTemplateColumn.CellTemplate>
                                            </sdk:DataGridTemplateColumn>
                                            <sdk:DataGridTemplateColumn CanUserReorder="False" Width="70" CanUserResize="False">
                                                <sdk:DataGridTemplateColumn.HeaderStyle>
                                                    <Style TargetType="sdk:DataGridColumnHeader">
                                                        <Setter Property="Template">
                                                            <Setter.Value>
                                                                <ControlTemplate>
                                                                    <Grid>
                                                                        <Rectangle Fill="#FF1F3B53" Stretch="Fill"/>

                                                                        <Rectangle Stretch="Fill" Fill="{StaticResource BackRectangleBrush}"/>

                                                                        <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch"
                                                                                   Width="1" HorizontalAlignment="Right"/>

                                                                        <TextBlock Text="Tues" HorizontalAlignment="Center"
                                                                                   VerticalAlignment="Center"/>
                                                                    </Grid>
                                                                </ControlTemplate>
                                                            </Setter.Value>
                                                        </Setter>
                                                    </Style>
                                                </sdk:DataGridTemplateColumn.HeaderStyle>
                                                <sdk:DataGridTemplateColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <Grid Margin="0" Background="{Binding Color}">
                                                            <Ellipse Width="8" Height="8" Fill="{Binding ForeColor}"
                                                                     Opacity="{Binding Tuesday}"
                                                                     HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                                        </Grid>
                                                    </DataTemplate>
                                                </sdk:DataGridTemplateColumn.CellTemplate>
                                            </sdk:DataGridTemplateColumn>
                                            <sdk:DataGridTemplateColumn CanUserReorder="False" Width="70" CanUserResize="False">
                                                <sdk:DataGridTemplateColumn.HeaderStyle>
                                                    <Style TargetType="sdk:DataGridColumnHeader">
                                                        <Setter Property="Template">
                                                            <Setter.Value>
                                                                <ControlTemplate>
                                                                    <Grid>
                                                                        <Rectangle Fill="#FF1F3B53" Stretch="Fill"/>

                                                                        <Rectangle Stretch="Fill" Fill="{StaticResource BackRectangleBrush}"/>

                                                                        <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch"
                                                                                   Width="1" HorizontalAlignment="Right"/>

                                                                        <TextBlock Text="Wed" HorizontalAlignment="Center"
                                                                                   VerticalAlignment="Center"/>
                                                                    </Grid>
                                                                </ControlTemplate>
                                                            </Setter.Value>
                                                        </Setter>
                                                    </Style>
                                                </sdk:DataGridTemplateColumn.HeaderStyle>
                                                <sdk:DataGridTemplateColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <Grid Margin="0" Background="{Binding Color}">
                                                            <Ellipse Width="8" Height="8" Fill="{Binding ForeColor}"
                                                                     Opacity="{Binding Wednesday}"
                                                                     HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                                        </Grid>
                                                    </DataTemplate>
                                                </sdk:DataGridTemplateColumn.CellTemplate>
                                            </sdk:DataGridTemplateColumn>
                                            <sdk:DataGridTemplateColumn CanUserReorder="False" Width="70" CanUserResize="False">
                                                <sdk:DataGridTemplateColumn.HeaderStyle>
                                                    <Style TargetType="sdk:DataGridColumnHeader">
                                                        <Setter Property="Template">
                                                            <Setter.Value>
                                                                <ControlTemplate>
                                                                    <Grid>
                                                                        <Rectangle Fill="#FF1F3B53" Stretch="Fill"/>

                                                                        <Rectangle Stretch="Fill" Fill="{StaticResource BackRectangleBrush}"/>

                                                                        <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch"
                                                                                   Width="1" HorizontalAlignment="Right"/>

                                                                        <TextBlock Text="Thur" HorizontalAlignment="Center"
                                                                                   VerticalAlignment="Center"/>
                                                                    </Grid>
                                                                </ControlTemplate>
                                                            </Setter.Value>
                                                        </Setter>
                                                    </Style>
                                                </sdk:DataGridTemplateColumn.HeaderStyle>
                                                <sdk:DataGridTemplateColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <Grid Margin="0" Background="{Binding Color}">
                                                            <Ellipse Width="8" Height="8" Fill="{Binding ForeColor}"
                                                                     Opacity="{Binding Thursday}"
                                                                     HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                                        </Grid>
                                                    </DataTemplate>
                                                </sdk:DataGridTemplateColumn.CellTemplate>
                                            </sdk:DataGridTemplateColumn>
                                            <sdk:DataGridTemplateColumn CanUserReorder="False" Width="70" CanUserResize="False">
                                                <sdk:DataGridTemplateColumn.HeaderStyle>
                                                    <Style TargetType="sdk:DataGridColumnHeader">
                                                        <Setter Property="Template">
                                                            <Setter.Value>
                                                                <ControlTemplate>
                                                                    <Grid>
                                                                        <Rectangle Fill="#FF1F3B53" Stretch="Fill"/>

                                                                        <Rectangle Stretch="Fill" Fill="{StaticResource BackRectangleBrush}"/>

                                                                        <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch"
                                                                                   Width="1" HorizontalAlignment="Right"/>

                                                                        <TextBlock Text="Fri" HorizontalAlignment="Center"
                                                                                   VerticalAlignment="Center"/>
                                                                    </Grid>
                                                                </ControlTemplate>
                                                            </Setter.Value>
                                                        </Setter>
                                                    </Style>
                                                </sdk:DataGridTemplateColumn.HeaderStyle>
                                                <sdk:DataGridTemplateColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <Grid Margin="0" Background="{Binding Color}">
                                                            <Ellipse Width="8" Height="8" Fill="{Binding ForeColor}" Opacity="{Binding Friday}"
                                                                 HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                                        </Grid>
                                                    </DataTemplate>
                                                </sdk:DataGridTemplateColumn.CellTemplate>
                                            </sdk:DataGridTemplateColumn>
                                        </sdk:DataGrid.Columns>
                                    </sdk:DataGrid>
                                </Grid>
                            </Border>
                        </DataTemplate>
                    </sdk:DataGrid.RowDetailsTemplate>
                    <sdk:DataGrid.Columns>
                        <sdk:DataGridTemplateColumn Header="First Name" CanUserResize="True" CanUserReorder="True"
                                                    Width="150">
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <sdk:Label Content="{Binding FirstName}" HorizontalAlignment="Left" Margin="5,2,2,2"
                                               VerticalAlignment="Center" Height="22"/>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTemplateColumn Header="Last Name" CanUserReorder="True" CanUserResize="True"
                                                    Width="150">
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <sdk:Label Content="{Binding LastName}" HorizontalAlignment="Left" Margin="5,2,2,2"
                                               VerticalAlignment="Center"/>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTemplateColumn Header="Department" CanUserReorder="True" CanUserResize="True"
                                                    Width="183">
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <sdk:Label Content="{Binding Department}" HorizontalAlignment="Left" Margin="5,2,2,2"
                                               VerticalAlignment="Center"/>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTemplateColumn Header="From" CanUserReorder="True" CanUserResize="True" Width="150">
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <sdk:Label Content="{Binding From, StringFormat='dd/MM/yyyy'}" HorizontalAlignment="Left"
                                               Margin="5,2,2,2" VerticalAlignment="Center"/>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTemplateColumn Header="To" CanUserReorder="True" CanUserResize="True" Width="150">
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <sdk:Label Content="{Binding To, StringFormat='dd/MM/yyyy'}" HorizontalAlignment="Left"
                                               VerticalAlignment="Center" Margin="5,2,2,2"/>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                    </sdk:DataGrid.Columns>
                </sdk:DataGrid>

                <sdk:DataPager PageSize="15" Source="{Binding Data, ElementName=ShAssignmentDataSource}"/>
            </StackPanel>
        </ScrollViewer>
    </Grid>
</navigation:Page>